package controllers;

import play.*;
import play.cache.Cache;
import play.libs.Codec;
import play.libs.Images;
import play.mvc.*;
import services.IndexService;
import services.OperatorService;
import utils.BizConstants;
import vos.ReturnCode;
import vos.SystemMenuView;

import java.util.*;

import org.apache.commons.lang.StringUtils;

import models.*;

public class Application extends BaseController {
    public static void index() {
        render();
    }
    /**
     * 获取风琴菜单父节点
     *
     * @Title: getAccordion 
     * @return: void
     */
    public static void getAccordion(){
    	Operator oper=getLoginUser();
    	List<SystemMenuView> relist=new ArrayList<SystemMenuView>();
    	relist=(List<SystemMenuView>) Cache.get(oper.operatorid+"_menu");
    	if(relist!=null){
    		renderJSON(relist);
    	}
    	else{
    		relist=new ArrayList<SystemMenuView>();
    	}
    	List<SystemMenuView> lists=IndexService.getMenu(oper.operatorid);
    	for(SystemMenuView menu : lists){
    		List<SystemMenuView> children=IndexService.getMenus(menu.operatorid,menu.menuid);
    		menu.setChildren(children);
    		relist.add(menu);
    	}
    	Cache.set(oper.operatorid+"_menu",relist);
    	renderJSON(relist);
    }
}